package step_2.checkers_board;

/**
 * A CheckersMove object represents a move in the game of Checkers.
 * It holds the row and column of the piece that is to be moved
 * and the row and column of the square to which it is to be moved.
 * (This class makes no guarantee that the move is legal.)   
 */
public class CheckersMove {
	int fromRow, fromCol;  // Position of piece to be moved.
	int toRow, toCol;      // Square it is to move to.
	CheckersMove(int r1, int c1, int r2, int c2) {
		// Constructor.  Just set the values of the instance variables.
		fromRow = r1;
		fromCol = c1;
		toRow = r2;
		toCol = c2;
	}
	public CheckersMove(CheckersMove m) {
		this.fromCol = m.fromCol;
		this.fromRow = m.fromRow;
		this.toCol = m.toCol;
		this.toRow = m.toRow;
	}
	boolean isJump() {
		// Test whether this move is a jump.  It is assumed that
		// the move is legal.  In a jump, the piece moves two
		// rows.  (In a regular move, it only moves one row.)
		return (fromRow - toRow == 2 || fromRow - toRow == -2);
	}
	@Override
	public String toString() {
		return "from " + (fromRow+1) + ", " + (fromCol+1)
				+ " to " + (toRow+1) + ", " + (toCol+1);
	}

}  // end class CheckersMove.
